package com.guguskins.back.service.impl;

import com.guguskins.back.entity.GuPrizeRecord;
import com.guguskins.back.mapper.GuPrizeRecordMapper;
import com.guguskins.back.mapper.GuUserMapper;
import com.guguskins.back.service.GuPrizeRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guguskins.back.service.GuTurntableService;
import com.guguskins.back.service.GuUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 奖品记录表 服务实现类
 * </p>
 *
 * @author mybatis-plus
 * @since 2021-07-15
 */
@Service
public class GuPrizeRecordServiceImpl extends ServiceImpl<GuPrizeRecordMapper, GuPrizeRecord> implements GuPrizeRecordService {
    @Autowired
    private GuUserService userService;
    @Autowired
    private GuTurntableService turntableService;
    @Autowired
    private GuPrizeRecordMapper prizeRecordMapper;

    @Override
    public List<GuPrizeRecord> findByList() {
        List<GuPrizeRecord> prizeRecords = prizeRecordMapper.selectList(null);
        prizeRecords.forEach(guPrizeRecord -> {
            guPrizeRecord.setGuUser(userService.getById(guPrizeRecord.getPrUserId()));
            guPrizeRecord.setGuTurntable(turntableService.findById(guPrizeRecord.getPrTurntableId()));
        });
        return prizeRecords;
    }
}
